﻿Write-Host $PSVersionTable.PSVersion
#get-netneighbor
#1..254 | ForEach-Object { Test-Connection -ComputerName "192.168.10.$_" -Count 1 -ErrorAction SilentlyContinue }
# 定义用户名和密码
write-host $systemInfo
$username = "think-pad"
$password = ConvertTo-SecureString "92730" -AsPlainText -Force

# 创建 PSCredential 对象
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
#Enable-WSManCredSSP -Role Client -DelegateComputer "192.168.10.253" -Force
#Enable-WSManCredSSP -Role Server
#Enable-PSRemoting -Force
#Restart-Service winrm
# 使用 credential 对象
#Get-WmiObject -Class Win32_ComputerSystem -ComputerName "192.168.10.253" -Credential $credential
#eventvwr
#dcomcnfg
#wmimgmt.msc
#secpol.msc
#$cimSession = New-CimSession -ComputerName "192.168.10.253" -Credential $credential
#Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName "192.168.10.253"  -CimSession $cimSession
#Enable-WSManCredSSP -Role Client -DelegateComputer "192.168.10.2"

$username2 = "admin"
$password2 = ConvertTo-SecureString @{} -AsPlainText -Force

# 创建 PSCredential 对象
$credential2 = New-Object System.Management.Automation.PSCredential($username, $password)
$session2 = new-pssession -ComputerName "192.168.10.253" -Credential $credential
$file = "D:\POWERSHELL\sshinit.ps1"
$file1 = "D:\党建2024年\"
$file2 = "C:\Users\11325\.ssh\id_rsa.pub"
$path = "C:\Users\think-pad\.ssh\authorized_keys"
#Copy-Item -Path $file2  -Destination $path -ToSession $session
#Remove-PSSession $session
#mstsc
# cmdkey /add:192.168.10.23 /user:308 /pass:92730
#Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "ImageTime" -Value "60000"